package org.learn.spring5.dao.impl;

import org.learn.spring5.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

@Component
public class UserDaoImpl implements UserDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;
    public int reduceMoney() {
    String sql=" update t_account set money=money-100 where user_name ='小明'";
        Object[] args = {};
        int update = jdbcTemplate.update(sql, args);

        return update;
    }

    public int addMoney() {
        String sql=" update t_account set money=money+100 where user_name ='小红'";
        Object[] args = {};
        int update = jdbcTemplate.update(sql, args);


        return update;
    }
}
